dojo.provide("lorelei.setClipboard");

lorelei.setClipboard.meta = {
"@prefix": "<http://purl.org/net/ns/doas#>",
"@about": "<http://mabinogi.logue.be/js/lolerei/setClipboard.js>", a: ":JavaScript",
 title: "Lorelei Clipboard Utility",
 shortdesc: "for use Clipboard when use not IE in this site.",
 created: "2008-06-09", release: {revision: "1.2.3", created: "2008-10-29"},
 author: {name: "Logue", homepage: "<http://logue.be/>"},
 license: "<http://www.gnu.org/licenses/gpl-3.0.html>",
 acknowledgement: {name :"mala", homepage :"<http://d.hatena.ne.jp/mala/>"}
};
// Lorelei Clipboard Utility
// Copyright (c)2008 Logue <http://logue.be/> All rights reserved.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

// based on setClipboard.js<http://la.ma.la/blog/diary_200601100445.htm> by mala<http://d.hatena.ne.jp/mala/>

console.log(lorelei.setClipboard.meta.title,lorelei.setClipboard.meta.release,' has been loaded.');

lorelei.setClipboard = function(text,callback){
	if (window.clipboardData){
		clipboardData.setData("Text", text);
	}else{
		//ie以外の場合flashを使いクリップボードにコピー
		var setClipboardUrl = dojo.moduleUrl("lorelei", "resource/setClipboard.swf"),flash;

		var tmp = document.createElement("div");
		embed = new dojox.embed.Flash({
			id: "embed",
			expressInstall:true,
			path:flash,
			width:0,
			height:0,
			style:{
				position :"absolute",
				left : "-10px",
				top  : "-10px",
				visibility: "hidden"
			},
			params:{
				swfLiveConnect:true,
				allowScriptAccess:'always'
				flashvars:{
					code:encodeURIComponent(text)
				}
			}
		},tmp);
/*
		tmp.innerHTML = [
			 '<embed src="', setClipboardUrl, '"'
			,' FlashVars="code=',encodeURIComponent(text),'"'
			,' width="0" height="0"'
			,'></embed>'
		].join("");
		with(tmp.style){
			position ="absolute";
			left = "-10px";
			top  = "-10px";
			visibility = "hidden";
		};
*/
		document.body.appendChild(tmp);
		setTimeout(function(){document.body.removeChild(tmp)},1000)
		return;

	}
	if (callback) callback;
	return;
}